﻿using RuoVea.ExDto;
using RuoVea.ExEnum;
using RuoVea.ExSugar.Attributes;
using RuoVea.ExSugar.Entity;
using SqlSugar;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace RuoVea.OmiApi.Dict.Entitys;

/// <summary>
/// 字典值表 - 存储系统字典值数据，支持多种数据类型和显示样式
/// </summary>
[SugarTable(nameof(SysDictValue))]
[Description("字典值表 - 存储系统字典值数据，支持多种数据类型和显示样式")]
[Tenant("0")]
[SugarIndex("index_{table}_TypeId", nameof(TypeId), OrderByType.Asc)]
[SugarIndex("index_{table}_TypeCode", nameof(TypeCode), OrderByType.Asc)]
[SugarIndex("index_{table}_Code", nameof(Code), OrderByType.Asc)]
[SugarIndex("index_{table}_Value", nameof(Value), OrderByType.Asc)]
public class SysDictValue : EntityBase, ITenantEntity
{
    /// <summary>
    /// 租户Id
    /// </summary>
    [ConfigSugarTenantColumn("TenantId", "租户Id", false, true, false)]
    public long? TenantId { get; set; }
    /// <summary>
    /// 字典类型Id - 关联SysDictType表的主键
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(TypeId), columnDescription: "字典类型Id - 关联SysDictType表的主键")]
    public long TypeId { get; set; }

    /// <summary>
    /// SysDictType表的编码 - 字典类型的唯一编码标识
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(TypeCode), columnDescription: "SysDictType表的编码 - 字典类型的唯一编码标识")]
    public string TypeCode { get; set; }

    /// <summary>
    /// 字典类型 - 导航属性，关联的字典类型对象
    /// </summary>
    [Newtonsoft.Json.JsonIgnore]
    [System.Text.Json.Serialization.JsonIgnore]
    [Navigate(NavigateType.OneToOne, nameof(TypeId))]
    public SysDictType DictType { get; set; }

    /// <summary>
    /// 显示文本 - 字典项的显示名称，如"首页主Banner"
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Label), columnDescription: "显示文本 - 字典项的显示名称，如'首页主Banner'", Length = 256)]
    [Required, MaxLength(256)]
    public string Label { get; set; }

    /// <summary>
    /// 值 - 字典项的实际值，支持多种数据类型：
    /// text: 文本值 | number: 数字 | color: 颜色代码 | image: 图片短路径或标识
    /// url: 短链接 | code: 代码标识 | boolean: true/false
    /// 对于长数据请使用ExtData字段扩展
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Value), columnDescription: "值 - 字典项的实际值(文本/数字/颜色/图片标识等)，长数据请用ExtData扩展", Length = 256)]
    [Required, MaxLength(256)]
    public string Value { get; set; }

    /// <summary>
    /// 编码 - 字典项的唯一编码标识，用于程序识别，如"HOME_CAROUSEL_1"
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Code), columnDescription: "编码 - 字典项的唯一编码标识，用于程序识别，如'HOME_CAROUSEL_1'", Length = 256, IsNullable = true)]
    [Required, MaxLength(256)]
    public string Code { get; set; }

    /// <summary>
    /// 排序 - 显示顺序，数值越小越靠前，默认10
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Sort), columnDescription: "排序 - 显示顺序，数值越小越靠前，默认10", IsNullable = true, DefaultValue = "10")]
    public int Sort { get; set; } = 10;

    /// <summary>
    /// 备注 - 字典项的详细描述信息，支持长文本说明
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Remark), columnDescription: "备注 - 字典项的详细描述信息，支持长文本说明", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string Remark { get; set; }

    /// <summary>
    /// 状态-正常_0、停用_1 - 控制字典项是否启用
    /// YesOrNot.N: 启用 | YesOrNot.Y: 禁用
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsDisable), columnDescription: "状态-正常_0、停用_1 - 控制字典项是否启用", IsNullable = true)]
    public YesOrNot? IsDisable { get; set; } = YesOrNot.N;

    /// <summary>
    /// 显示样式-标签类型 - 控制前端显示样式，支持以下类型：
    /// text: 文本 | badge: 徽章 | tag: 标签 | button: 按钮
    /// status: 状态指示 | progress: 进度条 | image: 图片
    /// json: JSON数据 | html: HTML内容 | date: 日期
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(TagType), columnDescription: "显示样式-标签类型 - 控制前端显示样式(text/badge/tag/button/status/image等)", Length = 16, IsNullable = true)]
    [MaxLength(16)]
    public string TagType { get; set; }

    /// <summary>
    /// 显示样式-Class - CSS类名，用于控制显示样式
    /// 如: "el-tag el-tag--success", "avatar avatar-lg"
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(ClassSetting), columnDescription: "显示样式-Class - CSS类名，用于控制显示样式", IsNullable = true, Length = 512)]
    [MaxLength(512)]
    public string ClassSetting { get; set; }

    /// <summary>
    /// 显示样式-Style - 内联样式，用于控制显示样式
    /// 如: "color: red; font-size: 14px", "width: 100px; height: 100px"
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(StyleSetting), columnDescription: "显示样式-Style - 内联样式，用于控制显示样式", IsNullable = true, Length = 512)]
    [MaxLength(512)]
    public string StyleSetting { get; set; }

    /// <summary>
    /// 是否默认值 - 标识是否为该类型的默认选项
    /// true: 默认值 | false: 非默认值
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsDefault), columnDescription: "是否默认值 - 标识是否为该类型的默认选项", IsNullable = true)]
    public bool? IsDefault { get; set; } = false;

    /// <summary>
    /// 拓展数据 - 存储JSON格式的扩展配置数据，用于存储复杂结构：
    /// 图片类型: {"imageUrl": "长URL", "width": 1200, "height": 400}
    /// 链接类型: {"linkUrl": "长URL", "target": "_blank"}
    /// 配置类型: {"settings": {}, "options": []}
    /// 长文本: {"content": "很长很长的文本内容..."}
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(ExtData), columnDescription: "拓展数据 - JSON格式的扩展配置，存储长URL、复杂结构、长文本等", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string ExtData { get; set; }
}